<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>基层AI辅助诊断系统 - 病历查询</title>
    <!-- 引入Element Plus的样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css">
    <!-- 引入Vue 3 -->
    <script src="https://unpkg.com/vue@3"></script>
    <!-- 引入Element Plus组件库 -->
    <script src="https://unpkg.com/element-plus"></script>
    <!-- 引入中文语言包 -->
    <script src="https://unpkg.com/element-plus/dist/locale/zh-cn.min.js"></script>
    <style>
        /* 基础样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
            background: #FFFFFF;
            color: var(--text-primary);
            font-size: 14px;
            line-height: 1.5;
            margin: 0;
        }

        /* 色彩系统 - 基于HIS系统现代极简风设计规范 */
        :root {
            /* 主色调 */
            --primary: #0F6CBD;
            --primary-light: #D0E7FF;
            --primary-dark: #0A4F8D;
            
            /* 辅助色 */
            --success: #0F8A5F;
            --warning: #F59337;
            --error: #D13438;
            --info: #0078D4;
            
            /* 中性色 - 文字 */
            --text-primary: #1A1A1A;
            --text-secondary: #4D4D4D;
            --text-tertiary: #767676;
            --text-disabled: #A6A6A6;
            
            /* 中性色 - 边框与分割线 */
            --border-strong: #CCCCCC;
            --border-normal: #E0E0E0;
            --border-light: #F0F0F0;
            --divider: #F5F5F5;
            
            /* 中性色 - 背景 */
            --bg-primary: #FFFFFF;
            --bg-secondary: #F9F9F9;
            --bg-card: #FFFFFF;
            --bg-disabled: #F5F5F5;
            
            /* 医疗专业色 */
            --medical-critical: #B91C1C;
            --medical-abnormal: #F59E0B;
            --medical-normal: #10B981;
            --medical-pending: #3B82F6;
            --medical-completed: #9CA3AF;
            
            /* 间距系统 */
            --spacing-2: 2px;
            --spacing-4: 4px;
            --spacing-8: 8px;
            --spacing-12: 12px;
            --spacing-16: 16px;
            --spacing-24: 24px;
            --spacing-32: 32px;
            --spacing-40: 40px;
            --spacing-48: 48px;
            
            /* 字体大小 */
            --font-page-title: 20px;
            --font-card-title: 16px;
            --font-table-title: 14px;
            --font-body: 14px;
            --font-table: 13px;
            --font-small: 12px;
            
            /* 行高 */
            --line-height-title: 1.4;
            --line-height-body: 1.5;
            --line-height-table: 1.2;
            --line-height-form: 1.4;
            
            /* 圆角 */
            --radius-small: 2px;
            --radius-medium: 4px;
            
            /* 动画时间 */
            --transition-fast: 150ms;
            --transition-normal: 200ms;
            --transition-slow: 300ms;
            
            /* 导航统一宽度 */
            --nav-item-width: 140px;
        }

        [v-cloak] {
            display: none;
        }

        /* 布局容器 */
        .container {
            width: 100%;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            background-color: var(--bg-secondary);
        }

        /* 顶部导航栏 */
        .header {
            height: 60px;
            background-color: var(--bg-primary);
            border-bottom: 1px solid var(--border-normal);
            display: flex;
            align-items: center;
            padding: 0 var(--spacing-24);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            position: relative;
            z-index: 100;
        }

        .header-spacer {
            width: 200px;
            flex-shrink: 0;
        }

        #app-nav {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            z-index: 10;
            width: calc(100% - 400px); /* 两侧各200px 对称留白 */
            display: flex;
            justify-content: center;
        }
        
        /* Element Plus菜单样式覆盖 */
        .el-menu {
            border: none !important;
            background-color: transparent !important;
        }
        
        .el-menu--horizontal > .el-menu-item,
        .el-menu--horizontal > .el-sub-menu .el-sub-menu__title {
            height: 60px;
            line-height: 60px;
            color: var(--text-secondary);
            font-weight: 500;
            font-size: var(--font-body);
            padding: 0;
            width: var(--nav-item-width);
            text-align: center;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
        }

        .el-sub-menu__icon-arrow { display: none !important; }

        .el-menu--horizontal > .el-sub-menu .el-sub-menu__title::after {
            content: '';
            display: inline-block;
            width: 16px;
            height: 16px;
            margin-left: 8px;
            background-repeat: no-repeat;
            background-position: center;
            background-size: 16px 16px;
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23767676' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
        }

        .el-sub-menu:hover > .el-sub-menu__title::after,
        .el-sub-menu.is-active > .el-sub-menu__title::after {
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230F6CBD' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
        }

        .el-sub-menu.is-opened > .el-sub-menu__title::after {
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230F6CBD' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 15 12 9 18 15'/></svg>");
        }
        
        .el-menu--horizontal > .el-menu-item.is-active,
        .el-menu--horizontal > .el-sub-menu.is-active .el-sub-menu__title {
            color: var(--primary) !important;
            border-bottom: 2px solid var(--primary);
            font-weight: 500;
        }
        
        .el-menu--horizontal > .el-menu-item:not(.is-disabled):hover,
        .el-menu--horizontal > .el-menu-item:not(.is-disabled):focus,
        .el-menu--horizontal > .el-sub-menu:not(.is-disabled):hover .el-sub-menu__title {
            color: var(--primary);
            background-color: transparent;
        }
        
        /* 下拉菜单样式覆盖 */
        .el-menu--popup {
            width: var(--nav-item-width) !important;
            min-width: var(--nav-item-width) !important;
            max-width: var(--nav-item-width) !important;
            border-radius: var(--radius-small);
            padding: 4px 0;
            border: 1px solid var(--border-light);
            border-top: 2px solid var(--primary);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            text-align: center !important;
        }
        
        .el-menu--popup .el-menu-item {
            height: 36px;
            line-height: 36px;
            padding: 0 !important;
            color: var(--text-secondary);
            white-space: nowrap;
            text-align: center;
            width: var(--nav-item-width) !important;
            box-sizing: border-box;
            overflow: hidden;
            text-overflow: ellipsis;
            display: flex !important;
            justify-content: center !important;
            align-items: center !important;
            font-size: var(--font-body);
        }
        
        .el-menu--popup .el-menu-item:hover {
            background-color: var(--bg-secondary);
            color: var(--primary);
        }

        .user-section {
            display: flex;
            align-items: center;
            gap: var(--spacing-16);
            margin-left: auto;
            z-index: 10;
            width: 200px;
            justify-content: flex-end;
            flex-shrink: 0;
            cursor: pointer;
            padding: 8px 12px;
            border-radius: var(--radius-small);
            transition: background-color var(--transition-fast);
            color: var(--text-secondary);
        }

        .user-section:hover {
            background-color: var(--bg-secondary);
        }

        .user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background-color: var(--primary-light);
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--primary);
            font-weight: 500;
        }

        .user-name {
            font-weight: 500;
            font-size: var(--font-body);
            color: var(--text-secondary);
        }

        .user-arrow {
            color: var(--text-tertiary);
            transition: color var(--transition-normal);
        }

        .user-section:hover .user-arrow {
            color: var(--primary);
        }

        /* 用户下拉弹窗 */
        .user-dropdown {
            position: absolute;
            top: 60px; /* 紧贴头部底部 */
            right: var(--spacing-24);
            width: 160px;
            background: var(--bg-primary);
            border: 1px solid var(--border-light);
            border-radius: var(--radius-small);
            box-shadow: 0 4px 12px rgba(0,0,0,0.08);
            display: none;
            z-index: 200;
            overflow: hidden;
        }

        .user-dropdown .item {
            padding: 10px 12px;
            color: var(--text-secondary);
            font-size: var(--font-body);
            cursor: pointer;
            white-space: nowrap;
        }

        .user-dropdown .item:hover {
            background-color: var(--bg-secondary);
            color: var(--primary);
        }

        /* 主要内容区域样式 */
        .main-content {
            padding: 0;
            flex: 1;
            background-color: var(--bg-primary);
            width: 100%;
        }
        
        .content-card {
            width: 100%;
            margin: 0;
            background: var(--bg-primary);
            border: none;
            border-radius: 0;
            box-shadow: none;
            display: flex;
            flex-direction: column;
        }

        /* 合并标题与查询条件区域样式 */
        .combined-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: var(--spacing-24);
            border-bottom: 1px solid var(--border-light);
            background-color: var(--bg-primary);
        }
        
        .page-title {
            font-size: var(--font-page-title);
            font-weight: 600;
            color: var(--text-primary);
            line-height: var(--line-height-title);
            margin-right: var(--spacing-24);
            white-space: nowrap;
        }

        .filter-container {
            display: flex;
            align-items: center;
            gap: var(--spacing-16);
            flex-wrap: nowrap;
        }

        .form-control {
            padding: var(--spacing-8) var(--spacing-12);
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            font-size: var(--font-body);
            color: var(--text-primary);
            transition: border-color var(--transition-normal);
            height: 32px;
        }
        
        .form-control:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.2);
        }

        .date-input {
            width: 140px;
        }

        .date-separator {
            color: var(--text-secondary);
            font-size: var(--font-body);
        }

        /* 按钮样式 */
        .btn {
            padding: var(--spacing-8) var(--spacing-16);
            border-radius: var(--radius-small);
            font-size: var(--font-body);
            font-weight: 500;
            cursor: pointer;
            border: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: all var(--transition-normal);
            gap: var(--spacing-8);
            height: 32px;
            line-height: 1;
        }
        
        .btn .icon {
            flex-shrink: 0;
        }
        
        .btn-primary {
            background-color: var(--primary);
            color: white;
        }
        
        .btn-primary:hover {
            background-color: var(--primary-dark);
        }
        
        .btn-primary:active {
            background-color: var(--primary-dark);
            transform: translateY(1px);
        }
        
        .btn-default {
            background-color: var(--bg-primary);
            color: var(--text-secondary);
            border: 1px solid var(--border-normal);
        }
        
        .btn-default:hover {
            background-color: var(--bg-secondary);
        }
        
        .btn-default:active {
            background-color: var(--bg-secondary);
            transform: translateY(1px);
        }
        
        /* 搜索框样式 */
        .search-box {
            position: relative;
            width: 240px;
        }
        
        .search-icon {
            position: absolute;
            left: 8px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-tertiary);
            pointer-events: none;
        }
        
        .search-box input {
            width: 100%;
            padding: var(--spacing-8) var(--spacing-8) var(--spacing-8) 32px;
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            font-size: 14px;
            color: var(--text-primary);
            transition: border-color 0.2s, box-shadow 0.2s;
        }
        
        .search-box input:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.2);
        }
        
        .search-box input::placeholder {
            color: var(--text-tertiary);
        }

        /* 表格区域样式 */
        .table-section {
            padding: var(--spacing-24);
            display: flex;
            flex-direction: column;
            gap: var(--spacing-24);
            background-color: var(--bg-primary);
        }

        /* 表格容器 */
        .table-container {
            background-color: var(--bg-primary);
            border-radius: var(--radius-small);
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
            overflow: auto;
            margin-bottom: var(--spacing-16);
            border: 1px solid var(--border-light);
        }
        
        .data-table {
            width: 100%;
            border-collapse: collapse;
        }
        
        .data-table th {
            background-color: var(--bg-secondary);
            padding: var(--spacing-12) var(--spacing-16);
            text-align: left;
            font-weight: 600;
            color: var(--text-secondary);
            border-bottom: 1px solid var(--border-normal);
            height: 40px;
            font-size: var(--font-table-title);
        }
        
        .data-table td {
            padding: var(--spacing-12) var(--spacing-16);
            border-bottom: 1px solid var(--border-light);
            color: var(--text-secondary);
            height: 40px;
            vertical-align: middle;
            font-size: var(--font-table);
        }
        
        .data-table tr:hover {
            background-color: var(--bg-secondary);
        }
        
        .data-table tr:last-child td {
            border-bottom: none;
        }

        /* 操作按钮样式 */
        .operations {
            display: inline-flex;
            gap: var(--spacing-8);
        }

        .operation-link {
            color: var(--primary);
            text-decoration: none;
        }

        .operation-link:hover {
            color: var(--primary-dark);
        }

        /* 空表格提示 */
        .empty-table-message {
            text-align: center;
            color: var(--text-tertiary);
            padding: var(--spacing-16);
            font-style: italic;
        }

        /* 表格底部区域 */
        .table-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: var(--spacing-16) var(--spacing-24);
        }

        /* 分页控件样式 */
        .pagination-text {
            color: var(--text-tertiary);
            font-size: var(--font-small);
        }

        .pagination-controls {
            display: flex;
            align-items: center;
            gap: var(--spacing-24);
        }

        .page-numbers {
            display: flex;
            gap: var(--spacing-8);
        }

        .page-numbers button {
            min-width: 32px;
            height: 32px;
            border-radius: var(--radius-small);
            border: 1px solid var(--border-normal);
            background: var(--bg-primary);
            cursor: pointer;
            color: var(--text-secondary);
            transition: all var(--transition-normal);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: var(--font-small);
        }

        .page-numbers button:hover {
            border-color: var(--primary);
            color: var(--primary);
        }

        .page-numbers button.active {
            background: var(--primary);
            border-color: var(--primary);
            color: #FFFFFF;
        }

        .pagination-size {
            display: flex;
            align-items: center;
            gap: var(--spacing-8);
            color: var(--text-secondary);
            font-size: var(--font-small);
        }

        .page-size-selector {
            height: 32px;
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            padding: 0 var(--spacing-8);
            font-size: var(--font-small);
            margin: 0 var(--spacing-4);
        }

        /* 响应式样式 */
        @media (max-width: 768px) {
            .header {
                flex-wrap: wrap;
                padding: var(--spacing-12) var(--spacing-16);
                height: auto;
            }
            
            .header-spacer {
                width: 100%;
                justify-content: center;
                margin-bottom: 8px;
            }
            
            .user-section {
                width: 100%;
                justify-content: center;
                order: 3;
                margin-top: 8px;
            }
            
            #app-nav {
                position: relative;
                left: 0;
                transform: none;
                width: 100%;
                order: 3;
                margin-top: var(--spacing-8);
            }
            
            /* Element Plus移动端菜单样式覆盖 */
            .el-menu--collapse {
                width: 100%;
            }
            
            .el-menu--horizontal {
                flex-wrap: wrap;
                width: 100%;
                overflow-x: auto;
                white-space: nowrap;
                -webkit-overflow-scrolling: touch;
                padding-bottom: var(--spacing-4);
                justify-content: center;
            }
            
            .el-menu--horizontal > .el-menu-item,
            .el-menu--horizontal > .el-sub-menu .el-sub-menu__title {
                height: 48px;
                line-height: 48px;
            }
            
            /* 移动端下拉菜单样式 */
            .el-menu--popup {
                position: fixed;
                top: auto !important;
                left: 0 !important;
                right: 0 !important;
                width: 100%;
                max-height: 60vh;
                overflow-y: auto;
                border-radius: 8px 8px 0 0;
            }
            
            .main-content {
                padding: 0;
            }
            
            .combined-header {
                flex-direction: column;
                align-items: flex-start;
                gap: var(--spacing-16);
            }
            
            .page-title {
                margin-bottom: var(--spacing-16);
            }
            
            .filter-container {
                flex-direction: column;
                width: 100%;
                gap: var(--spacing-12);
            }
            
            .form-control, .date-input {
                width: 100%;
            }
            
            .date-separator {
                display: none;
            }
            
            .table-container {
                overflow-x: auto;
            }
            
            .data-table {
                min-width: 800px;
            }
            
            .table-footer {
                flex-direction: column;
                gap: var(--spacing-16);
                align-items: flex-start;
            }
            
            .pagination-controls {
                flex-direction: column;
                gap: var(--spacing-16);
                align-items: flex-start;
                width: 100%;
            }
            
            .page-numbers {
                flex-wrap: wrap;
                justify-content: flex-start;
                width: 100%;
            }
        }
    </style>
</head>
<body>
    <div id="app" class="container">
        <!-- 顶部导航栏 - 使用Element Plus组件 -->
        <header class="header">
            <div class="header-spacer"></div>
            <div id="app-nav">
                <el-menu 
                    :default-active="activeIndex" 
                    class="el-menu-demo" 
                    mode="horizontal" 
                    @select="handleSelect"
                    :ellipsis="false"
                    :popper-offset="0"
                    popper-class="custom-dropdown">
                    <el-menu-item index="1">开始问诊</el-menu-item>
                    <el-sub-menu index="2" popper-class="custom-dropdown">
                        <template #title>病历管理</template>
                        <el-menu-item index="2-1">病历查询</el-menu-item>
                        <el-menu-item index="2-2">病历模板</el-menu-item>
                        <el-menu-item index="2-3">个人药品</el-menu-item>
                    </el-sub-menu>
                    <el-menu-item index="3">患者管理</el-menu-item>
                    <el-sub-menu index="4" popper-class="custom-dropdown">
                        <template #title>数据统计</template>
                        <el-menu-item index="4-1">诊断统计</el-menu-item>
                        <el-menu-item index="4-2">宏观统计</el-menu-item>
                    </el-sub-menu>
                    <el-menu-item index="5">医学知识</el-menu-item>
                    <el-sub-menu index="6" popper-class="custom-dropdown">
                        <template #title>基础数据</template>
                        <el-menu-item index="6-1">药品管理</el-menu-item>
                    </el-sub-menu>
                    <el-sub-menu index="7" popper-class="custom-dropdown">
                        <template #title>消息通知</template>
                        <el-menu-item index="7-1">通知查看</el-menu-item>
                        <el-menu-item index="7-2">通知发布</el-menu-item>
                    </el-sub-menu>
                    <el-sub-menu index="8" popper-class="custom-dropdown">
                        <template #title>用户管理</template>
                        <el-menu-item index="8-1">用户管理</el-menu-item>
                        <el-menu-item index="8-2">角色管理</el-menu-item>
                    </el-sub-menu>
                </el-menu>
            </div>
            <div class="user-section" id="userSection">
                <span class="user-name">张医生</span>
                <svg class="user-arrow" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                    <polyline points="6 9 12 15 18 9"></polyline>
                </svg>
            </div>
            <div class="user-dropdown" id="userDropdown">
                <div class="item">个人中心</div>
                <div class="item">退出登录</div>
            </div>
        </header>
        <div class="main-content">
            <div class="content-card">
                <section class="combined-header">
                    <h1 class="page-title">病历查询</h1>
                    <div class="filter-container">
                        <input id="keyword" class="form-control" type="text" placeholder="输入患者姓名或疾病类型">
                        <input id="startDate" class="form-control date-input" type="date" placeholder="开始日期">
                        <span class="date-separator">至</span>
                        <input id="endDate" class="form-control date-input" type="date" placeholder="结束日期">
                        <button id="searchBtn" class="btn btn-primary">查询</button>
                        <button id="resetBtn" class="btn btn-default">重置</button>
                    </div>
                </section>
                <section class="table-section">
                    <div class="table-container">
                        <table class="data-table">
                            <thead>
                                <tr>
                                    <th>患者姓名</th>
                                    <th>性别</th>
                                    <th>年龄</th>
                                    <th>上次就诊</th>
                                    <th>诊断结果</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody id="recordBody">
                                <!-- 表格内容将通过JavaScript动态生成 -->
                            </tbody>
                        </table>
                    </div>
                    <div class="table-footer">
                        <div class="pagination-text" id="summaryText">共 <span id="totalRecords">120</span> 条记录</div>
                        <div class="pagination-controls">
                            <div id="pageNumbers" class="page-numbers">
                                <button class="active">1</button>
                                <button>2</button>
                                <button>3</button>
                                <button>4</button>
                                <button>5</button>
                            </div>
                            <div class="pagination-size">
                                每页显示
                                <select id="pageSizeSelector" class="page-size-selector">
                                    <option value="10">10</option>
                                    <option value="20">20</option>
                                    <option value="50">50</option>
                                </select>
                                条
                            </div>
                        </div>
                    </div>
                </section>
            </div>
        </div>
    </div>

    <!-- JavaScript 交互逻辑 -->
    <script>
        // 创建Vue应用
        document.addEventListener('DOMContentLoaded', function() {
            const { createApp, ref } = Vue;
            
            // 创建导航菜单Vue应用
            const navApp = createApp({
                setup() {
                    const activeIndex = ref('2-1'); // 默认选中"病历查询"
                    
                    const handleSelect = (key, keyPath) => {
                        console.log(key, keyPath);
                        // 这里可以添加导航逻辑，如页面跳转等
                    };
                    
                    return {
                        activeIndex,
                        handleSelect
                    };
                }
            });
            
            // 使用Element Plus
            navApp.use(ElementPlus, {
                locale: ElementPlusLocaleZhCn
            });
            
            // 挂载Vue应用
            navApp.mount('#app-nav');

            // 模拟病历数据
            const records = [
                { id: '001', name: '张三', gender: '男', age: '35岁', date: '2025-09-28', diagnosis: '上呼吸道感染' },
                { id: '002', name: '李四', gender: '男', age: '42岁', date: '2025-09-27', diagnosis: '高血压' },
                { id: '003', name: '王五', gender: '男', age: '28岁', date: '2025-09-26', diagnosis: '感冒' },
                { id: '004', name: '赵六', gender: '女', age: '45岁', date: '2025-09-25', diagnosis: '糖尿病' },
                { id: '005', name: '钱七', gender: '女', age: '31岁', date: '2025-09-24', diagnosis: '头痛' },
                { id: '006', name: '孙八', gender: '男', age: '52岁', date: '2025-09-23', diagnosis: '关节炎' },
                { id: '007', name: '周九', gender: '女', age: '27岁', date: '2025-09-22', diagnosis: '皮炎' },
                { id: '008', name: '吴十', gender: '男', age: '33岁', date: '2025-09-21', diagnosis: '胃炎' },
                { id: '009', name: '郑十一', gender: '女', age: '38岁', date: '2025-09-20', diagnosis: '结膜炎' },
                { id: '010', name: '王十二', gender: '男', age: '41岁', date: '2025-09-19', diagnosis: '腰肌劳损' },
                { id: '011', name: '李十三', gender: '女', age: '29岁', date: '2025-09-18', diagnosis: '咽炎' },
                { id: '012', name: '张十四', gender: '男', age: '47岁', date: '2025-09-17', diagnosis: '高血脂' }
            ];

            // 获取DOM元素
            const keywordInput = document.getElementById('keyword');
            const startInput = document.getElementById('startDate');
            const endInput = document.getElementById('endDate');
            const searchBtn = document.getElementById('searchBtn');
            const resetBtn = document.getElementById('resetBtn');
            const recordBody = document.getElementById('recordBody');
            const totalRecordsEl = document.getElementById('totalRecords');
            
            // 分页相关元素
            const pageNumbersEl = document.getElementById('pageNumbers');
            const pageSizeSelector = document.getElementById('pageSizeSelector');

            // 分页状态
            let filtered = [...records];
            let pageSize = 10;
            let currentPage = 1;
            let totalPages = Math.ceil(filtered.length / pageSize);

            // 渲染表格数据
            function renderTable() {
                // 计算当前页数据
                const start = (currentPage - 1) * pageSize;
                const end = start + pageSize;
                const pageData = filtered.slice(start, end);
                
                // 清空表格内容
                recordBody.innerHTML = '';
                
                // 如果没有数据，显示空表格提示
                if (pageData.length === 0) {
                    const emptyRow = document.createElement('tr');
                    emptyRow.innerHTML = `<td colspan="6" class="empty-table-message">暂无符合条件的病历记录</td>`;
                    recordBody.appendChild(emptyRow);
                } else {
                    // 渲染数据行
                    pageData.forEach(record => {
                        const row = document.createElement('tr');
                        row.innerHTML = `
                            <td>${record.name}</td>
                            <td>${record.gender}</td>
                            <td>${record.age}</td>
                            <td>${record.date}</td>
                            <td>${record.diagnosis}</td>
                            <td>
                                <div class="operations">
                                    <a class="operation-link" href="#" onclick="viewDetail('${record.id}')">详情</a>
                                    <a class="operation-link" href="#" onclick="editRecord('${record.id}')">编辑</a>
                                    <a class="operation-link" href="#" style="color:var(--error);" onclick="deleteRecord('${record.id}')">删除</a>
                                </div>
                            </td>
                        `;
                        recordBody.appendChild(row);
                    });
                }
                
                // 更新总记录数显示
                totalRecordsEl.textContent = filtered.length;
                
                // 更新分页控件
                renderPagination();
            }

            // 渲染分页控件
            function renderPagination() {
                totalPages = Math.ceil(filtered.length / pageSize);
                
                // 更新页码状态
                
                // 渲染页码按钮
                pageNumbersEl.innerHTML = '';
                
                // 计算需要显示的页码范围
                let startPage = Math.max(1, currentPage - 2);
                let endPage = Math.min(totalPages, startPage + 4);
                
                // 调整起始页，确保显示5个页码
                if (endPage - startPage < 4 && totalPages > 4) {
                    startPage = Math.max(1, endPage - 4);
                }
                
                // 创建页码按钮
                for (let i = startPage; i <= endPage; i++) {
                    const pageBtn = document.createElement('button');
                    pageBtn.textContent = i;
                    pageBtn.className = i === currentPage ? 'active' : '';
                    pageBtn.addEventListener('click', () => {
                        currentPage = i;
                        renderTable();
                    });
                    pageNumbersEl.appendChild(pageBtn);
                }
            }

            // 应用筛选条件
            function applyFilter() {
                const keyword = keywordInput.value.trim().toLowerCase();
                const startDate = startInput.value;
                const endDate = endInput.value;
                
                filtered = records.filter(record => {
                    // 智能搜索：匹配姓名或诊断结果
                    const matchKeyword = keyword ? 
                        record.name.toLowerCase().includes(keyword) || 
                        record.diagnosis.toLowerCase().includes(keyword) : true;
                    
                    // 日期范围匹配
                    const matchStart = startDate ? record.date >= startDate : true;
                    const matchEnd = endDate ? record.date <= endDate : true;
                    
                    return matchKeyword && matchStart && matchEnd;
                });
                
                // 重置为第一页并重新渲染
                currentPage = 1;
                renderTable();
            }

            // 重置筛选条件
            function resetFilters() {
                keywordInput.value = '';
                startInput.value = '';
                endInput.value = '';
                filtered = [...records];
                currentPage = 1;
                renderTable();
            }

            // 绑定事件处理函数
            searchBtn.addEventListener('click', applyFilter);
            resetBtn.addEventListener('click', resetFilters);
            
            // 每页显示数量选择器事件
            pageSizeSelector.addEventListener('change', () => {
                pageSize = parseInt(pageSizeSelector.value);
                currentPage = 1;
                renderTable();
            });

            // 用户下拉菜单
            const userSection = document.getElementById('userSection');
            const userDropdown = document.getElementById('userDropdown');
            
            if (userSection && userDropdown) {
                userSection.addEventListener('click', function(e) {
                    e.stopPropagation();
                    const isOpen = userDropdown.style.display === 'block';
                    userDropdown.style.display = isOpen ? 'none' : 'block';
                });

                document.addEventListener('click', function() {
                    userDropdown.style.display = 'none';
                });
            }

            // 初始化表格
            renderTable();
        });

        // 病历操作函数
        function viewDetail(id) {
            alert(`查看病历详情：${id}`);
            // 实际应用中可以跳转到详情页或打开详情弹窗
        }
        
        function editRecord(id) {
            alert(`编辑病历：${id}`);
            // 实际应用中可以跳转到编辑页面
        }
        
        function deleteRecord(id) {
            if (confirm(`确定要删除病历 ${id} 吗？`)) {
                alert(`已删除病历：${id}`);
                // 实际应用中可以调用删除API，然后刷新表格
            }
        }
    </script>
</body>
</html>
